package com.ssy.lingxi.settle.accounts.model.vo.response;

import com.ssy.lingxi.common.constant.basic.PurchaseContractPayTypeEnum;
import com.ssy.lingxi.dto.model.constant.ApplyAmountRowBillTypeEnum;
import com.ssy.lingxi.settle.accounts.model.constant.SettleAccountsServiceContants;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Objects;

/**
 * 待对账单列表行信息VO
 * @author Saske
 * @date 2021/12/6
 * @version 2.0.0
 */
public class ToBeReconciliationRowVO implements Serializable {

    private static final long serialVersionUID = -8883760826249570038L;

    public ToBeReconciliationRowVO(Long productId, Integer payWay, Integer payMouth, Integer payDay, LocalDateTime expectPayTime, String productNo, String productName, String spec, String category, String brand, String unit, BigDecimal taxRate, BigDecimal price, BigDecimal receiveQuantity, BigDecimal reconciledQuantity, BigDecimal reconciledMoney, BigDecimal reconciliationQuantity, Integer billType) {
        boolean negateFlag = Objects.equals(billType, ApplyAmountRowBillTypeEnum.RETURN_REQUEST.getCode());
        this.productId = productId;
        this.payWay = payWay;
        this.payWayName = Objects.nonNull(payWay) ? PurchaseContractPayTypeEnum.getNameByCode(payWay) : "-";
        this.expectPayTime = expectPayTime.format(SettleAccountsServiceContants.DEFAULT_TIME_FORMATTER);
        this.productNo = productNo;
        this.productName = productName;
        this.spec = spec;
        this.category = category;
        this.brand = brand;
        this.unit = unit;
        this.taxRate = taxRate;
        this.price = price;
        this.receiveQuantity = receiveQuantity;
        this.reconciledQuantity = reconciledQuantity;
        this.reconciledMoney = reconciledMoney;
        this.reconciliationQuantity = reconciliationQuantity;
        this.reconciliationMoneyAmount = negateFlag
                ? reconciliationQuantity.multiply(price).negate()
                : reconciliationQuantity.multiply(price);
    }

    /**
     * 待对账单商品明细Id
     */
    private Long productId;

    /**
     * 结算方式
     * 定义：PurchaseContractPayTypeEnum
     */
    private Integer payWay;

    /**
     * 结算方式名称
     */
    private String payWayName;

    /**
     * 预计结算日期
     */
    private String expectPayTime;

    /**
     * 物料编号
     */
    private String productNo;

    /**
     * 物料名称
     */
    private String productName;

    /**
     * 商品规格/型号
     */
    private String spec;

    /**
     * 商品品类
     */
    private String category;

    /**
     * 商品品牌
     */
    private String brand;

    /**
     * 单位
     */
    private String unit;

    /**
     * 税率（百分比的分子部分）
     */
    private BigDecimal taxRate;

    /**
     * 单价（含税）
     */
    private BigDecimal price;

    /**
     * 收货数量
     */
    private BigDecimal receiveQuantity;

    /**
     * 已对账数量
     */
    private BigDecimal reconciledQuantity;

    /**
     * 已对账金额（含税）
     */
    private BigDecimal reconciledMoney;

    /**
     * 待对账数量
     */
    private BigDecimal reconciliationQuantity;

    /**
     * 待对账金额（含税）
     */
    private BigDecimal reconciliationMoneyAmount;

    public Long getProductId() {
        return productId;
    }

    public void setProductId(Long productId) {
        this.productId = productId;
    }

    public Integer getPayWay() {
        return payWay;
    }

    public void setPayWay(Integer payWay) {
        this.payWay = payWay;
    }

    public String getExpectPayTime() {
        return expectPayTime;
    }

    public void setExpectPayTime(String expectPayTime) {
        this.expectPayTime = expectPayTime;
    }

    public String getProductNo() {
        return productNo;
    }

    public void setProductNo(String productNo) {
        this.productNo = productNo;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public String getSpec() {
        return spec;
    }

    public void setSpec(String spec) {
        this.spec = spec;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    public BigDecimal getTaxRate() {
        return taxRate;
    }

    public void setTaxRate(BigDecimal taxRate) {
        this.taxRate = taxRate;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public BigDecimal getReceiveQuantity() {
        return receiveQuantity;
    }

    public void setReceiveQuantity(BigDecimal receiveQuantity) {
        this.receiveQuantity = receiveQuantity;
    }

    public BigDecimal getReconciledQuantity() {
        return reconciledQuantity;
    }

    public void setReconciledQuantity(BigDecimal reconciledQuantity) {
        this.reconciledQuantity = reconciledQuantity;
    }

    public BigDecimal getReconciledMoney() {
        return reconciledMoney;
    }

    public void setReconciledMoney(BigDecimal reconciledMoney) {
        this.reconciledMoney = reconciledMoney;
    }

    public BigDecimal getReconciliationQuantity() {
        return reconciliationQuantity;
    }

    public void setReconciliationQuantity(BigDecimal reconciliationQuantity) {
        this.reconciliationQuantity = reconciliationQuantity;
    }

    public BigDecimal getReconciliationMoneyAmount() {
        return reconciliationMoneyAmount;
    }

    public void setReconciliationMoneyAmount(BigDecimal reconciliationMoneyAmount) {
        this.reconciliationMoneyAmount = reconciliationMoneyAmount;
    }

    public String getPayWayName() {
        return payWayName;
    }

    public void setPayWayName(String payWayName) {
        this.payWayName = payWayName;
    }
}
